#!/bin/sh

#   Trivial pseudo random number generator
#
#   Copyright (C) 2009 Ultratronik Entwicklungs GmbH
#     - Author: Sören Wellhöfer <soeren.wellhoefer@gmx.net>.
#

usage() {
    echo "$0 MAX [MIN]"
}

if test "$1" == "-h"; then
    usage
    exit
fi

MAX=$1

if test -z "$MAX"; then
    echo "No maximum given"
    usage
    exit
fi

if test -z "$2"; then
    MIN=0
else
    MIN=$2
fi

RND=$(($(expr $(($$)) \* $(date +%S)) % ($MAX - $MIN) + $MIN))

echo $RND
